//
//  NSVipBuyPopView.m
//  Meboo
//
//  Created by kyo on 2024/5/17.
//

#import "NSVipBuyPopView.h"
@interface NSVipBuyPopView ()
@property(nonatomic,strong) UIImageView *backImageView;
@property(nonatomic,strong) UIImageView *vipImageView;
@property(nonatomic,strong) UILabel *titleLab;
@property(nonatomic,strong) UILabel *subTitleLab;
@property(nonatomic,strong) UIButton *getBtn;
@property (nonatomic, strong) UIButton *closeBtn;
@end
@implementation NSVipBuyPopView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Private Method


#pragma mark - Action
-(void)closePop {
    self.hidden = YES;
//    [self removeFromSuperview];
}

#pragma mark - UI
- (void)setupUI {
    self.hidden = YES;
    self.backgroundColor = [UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0.5];
    
    [self addSubview:self.backImageView];
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.width.mas_equalTo(ScreenWidth-MBWidthScale(40));
    }];
    
    [self.backImageView addSubview:self.vipImageView];
    [self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(MBHeightScale(26));
        make.centerX.equalTo(self);
        make.height.mas_equalTo(MBWidthScale(169)/169*125);
        make.width.mas_equalTo(MBWidthScale(169));
    }];
    
    [self.backImageView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.vipImageView.mas_bottom).offset(MBHeightScale(24));
    }];
    
    [self.backImageView addSubview:self.subTitleLab];
    [self.subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(MBWidthScale(-25));
        make.left.mas_equalTo(MBWidthScale(25));
        make.top.equalTo(self.titleLab.mas_bottom).offset(MBHeightScale(11));
    }];
    
    [self.backImageView addSubview:self.getBtn];
    [self.getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.subTitleLab.mas_bottom).offset(MBHeightScale(25));
        make.left.mas_equalTo(MBWidthScale(10));
        make.centerX.equalTo(self);
        make.height.mas_equalTo((ScreenWidth-MBWidthScale(60))/314*48);
        make.bottom.mas_equalTo(MBHeightScale(-25));
    }];
    
    [self.backImageView addSubview:self.closeBtn];
    [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.backImageView.mas_right).offset(MBWidthScale(-17));
        make.top.equalTo(self.backImageView.mas_top).offset(MBWidthScale(17));
        make.width.height.mas_offset(MBHeightScale(18));
    }];
}

#pragma mark - Setter && Getter

- (UIImageView *)backImageView {
    if (!_backImageView) {
        _backImageView = [UIImageView new];
        _backImageView.userInteractionEnabled = YES;
        _backImageView.image = ImageWithName(@"vip_paysuccess_pop_back");
    }
    return _backImageView;
}

- (UIImageView *)vipImageView {
    if (!_vipImageView) {
        _vipImageView = [UIImageView new];
        _vipImageView.image = ImageWithName(@"vip_paysuccess_pop_crown");
    }
    return _vipImageView;
}

- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = MBHelBoldFontSizeScale(18);
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.textColor = HEXS(@"ffffff");
        _titleLab.text = @"Welcome to Meboo";
    }
    return _titleLab;
}

- (UILabel *)subTitleLab {
    if (!_subTitleLab) {
        _subTitleLab = [UILabel new];
        _subTitleLab.numberOfLines = 0;
        _subTitleLab.textAlignment = NSTextAlignmentCenter;
        _subTitleLab.font = MBHelFontSizeScale(16);
        _subTitleLab.textColor = HEXS(@"ffffff");
        _subTitleLab.text = @"With unlimited daily swipes, won't missevery change to meet your crush!";
    }
    return _subTitleLab;
}

- (UIButton *)getBtn {
    if (!_getBtn) {
        _getBtn = [UIButton new];
        [_getBtn setTitle:@"Get it!" forState:0];
        [_getBtn setYXEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
        [_getBtn setTitleColor:HEXS(@"8E4AE7") forState:0];
        _getBtn.titleLabel.font = MBHelBoldFontSizeScale(18);
        [_getBtn setBackgroundColor:HEXS(@"ffffff")];
        _getBtn.layer.cornerRadius = (ScreenWidth-MBWidthScale(60))/314*48/2.0;
        [_getBtn addTarget:self action:@selector(closePop) forControlEvents:UIControlEventTouchUpInside];
    }
    return _getBtn;
}

- (UIButton *)closeBtn {
    if (!_closeBtn) {
        _closeBtn = [UIButton new];
        [_closeBtn setYXEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
        [_closeBtn setBackgroundImage:ImageWithName(@"flash_chat_close") forState:0];
        [_closeBtn addTarget:self action:@selector(closePop) forControlEvents:UIControlEventTouchUpInside];
    }
    return _closeBtn;
}
@end
